package com.kis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.kis.pojo.User;
import com.kis.service.UserService;

@Controller
public  class HelloController {
	@Autowired
	UserService us;
	//映射
	@RequestMapping(method=RequestMethod.GET,value="/hello")
	public ModelAndView hello() {
		ModelAndView mv = new ModelAndView();
		mv.addObject("name", "kis by spring mvc ");
		System.out.println("aaaaaaaaaaa");
		mv.setViewName("hello");
		return mv;
	}

	@RequestMapping(method=RequestMethod.POST,value="/addUser")
	public ModelAndView addUser(@ModelAttribute("user") User u){
		ModelAndView mv = new ModelAndView("hello");
		System.out.println(u.getUsername());
		System.out.println(u.getPassword());
		return mv;
	}
}
